<template>
  <div class="login">
    <van-nav-bar
    title="修改密码"
    left-arrow
    @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        label="旧密码"
        placeholder="旧密码"
        :rules="[{ required: true, message: '请输入旧密码' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="新密码"
        placeholder="新密码"
        :rules="[{ required: true, message: '请输入新密码' }]"
      />
      <div class="dz">
        <router-link to="/login" class="dl">登录</router-link>
      </div>
      <!-- <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">登录</van-button>
      </div> -->
       <div style="margin: 16px">
      <van-button
        round
        block
        type="info"
        native-type="submit"
        class="btn"
        >确定</van-button
      >
    </div>
    </van-form>
  </div>
</template>

<script>
import { Form } from 'vant';
import { Field } from 'vant';
export default {
  name: "WorkspaceJsonLogin",
  components:{
    [Form.name]:Form,
    [Field.name]:Field,
  },
  data() {
    return {
      username:'',
      password:'',
    };
  },

  methods: {
    onClickLeft(){
        this.$router.go(-1)
    },
    // 登录
    onSubmit() {
      let {username,password}=this;
      this.uid=localStorage.getItem('uid')
      this.$http.post('/user/updatePwd',{
        oldPassword:username,
        newPassword:password,
        uid:this.uid
      })
      .then(res=>{
        console.log(res);
         this.$toast(res.msg)
        // if(res.code==0){
        //   setTimeout(()=>{
        //     this.$router.go(-1);
        //   },800)
        // }
      })
    },
    
  },
  mounted() {}

};
</script>

<style lang="scss" scoped>
.dl{
  color: #fff;
  font-size: 14px;
  font-weight: normal;

}
.dz{
  border-radius:7px ;
  background: #2196f3;
  width: 50px;
  text-align: center;
  margin-top: 10px;
  margin-left: 10px;
}
.btn {
  background:#2196f3;
  border: none;
  border-radius: 0;
  width: 300px;
  margin-left: 27px;
  margin-top: 10px;
}
.dz{
  padding: 5px 7px;
  span{
    display: inline-block;
    margin-left: 61.6vw;
  }
}
</style>